<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传表单</title>
    <script src="//cdn.bootcss.com/jquery/2.2.0/jquery.min.js"></script>
    <script src="//cdn.bootcss.com/jquery.form/3.51/jquery.form.js"></script>
</head>
<body>
<form id="upform" action="phpClient.php" enctype="multipart/form-data" method="post">
    <input type="file" name="file" id="selectimage" onchange="upload();">
    <button type="submit">上传</button>
</form>


<script>
    function upload(){
        //判断上传文件的类型
        var filepath=$("#selectimage").val();
        var extStart=filepath.lastIndexOf(".");
        var ext=filepath.substring(extStart,filepath.length).toUpperCase();
        if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
            alert("这不是一个正确的图片");
            return false;
        }
        $("#upform").submit();
        selectimage.disabled='disabled';
    };


</script>
</body>
</html>